<?php

class ForgotPasswordForm extends CFormModel {

	public $userEmail;

	/**
	 * Declares the validation rules.
	 * The rules state that username and userPhone are required,
	 * and password needs to be authenticated.
	 */
	public function rules() {
		return array(
			array('userEmail', 'required'),
			array('userEmail', 'email'),
			array('userEmail', 'UserCheck'),
		);
	}

	public function UserCheck() {
		$c = new CDbCriteria();
		$c->compare('"userEmail"', $this->userEmail);
		$user = Users::model()->find($c);
		if ($user === NULL)
			$this->addError('userEmail', 'E-mail не найден в базе, будьте внимательны.');
	}

	/**
	 * Declares attribute labels.
	 */
	public function attributeLabels() {
		return array(
			'userEmail' => 'E-mail',
		);
	}

}
